package com.gzhryc.jdbc.models;

import java.io.Serializable;

public abstract class LRTree<R> implements Serializable{
	
	private static final long serialVersionUID = 1L;

	public abstract R getId();
	
	public abstract R getParentId();
	
	public abstract void setParentId(R parentId);
	
	public abstract R getRootId();
	
	public abstract void setRootId(R rootId);

	public abstract Long getLeftNum();
	
	public abstract void setLeftNum(Long leftNum);
	
	public abstract Long getRightNum();
	
	public abstract void setRightNum(Long rightNum);
	
	public boolean getIsLeaf(){
		if(getLeftNum() != null && getRightNum() != null){
			return getRightNum() - getLeftNum()  == 1;
		}
		return true;
	}
	
	public boolean getIsRoot() {
		if(getParentId() == null || getId().equals(getRootId())) {
			return true;
		}
		return false;
	}
}
